package com.zhu.transaction.mapper.imp;

import com.zhu.transaction.mapper.ProductMapper;
import com.zhu.transaction.pojo.Product;
import com.zhu.transaction.pojo.ProductCondition;
import com.zhu.transaction.pojo.reports.ProductReports;
import com.zhu.transaction.pojo.state.BackState;
import com.zhu.transaction.service.ProductService;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Zhu
 * @createtime 2021/1/27-8:58
 */
@Repository
public class ProductMapperImp implements ProductMapper {
    @Autowired
    SqlSession sqlSession;

    @Override
    public int addProduct(Product product) {
        return sqlSession.getMapper(ProductMapper.class).addProduct(product);
    }

    @Override
    public List<Product> queryAllProduct(String id) {
        return sqlSession.getMapper(ProductMapper.class).queryAllProduct(id);
    }

    @Override
    public List<Product> queryProductByPage(ProductCondition productCondition, Integer index, Integer num) {
        return sqlSession.getMapper(ProductMapper.class).queryProductByPage(productCondition, index, num);
    }

    @Override
    public Product queryProductByID(String id) {
        return sqlSession.getMapper(ProductMapper.class).queryProductByID(id);
    }

    @Override
    public List<Product> queryProductByUserID(String userId, Integer index) {
        return sqlSession.getMapper(ProductMapper.class).queryProductByUserID(userId, index);
    }

    @Override
    public int queryProductNum(String userId, ProductCondition productCondition) {
        return sqlSession.getMapper(ProductMapper.class).queryProductNum(userId, productCondition);
    }

    @Override
    public Product queryProductByFavoriteId(String favoriteId) {
        return sqlSession.getMapper(ProductMapper.class).queryProductByFavoriteId(favoriteId);
    }

    @Override
    public List<ProductReports> queryNewProductReports() {
        return sqlSession.getMapper(ProductMapper.class).queryNewProductReports();
    }

    @Override
    public List<ProductReports> queryCategoryProductReports() {
        return sqlSession.getMapper(ProductMapper.class).queryCategoryProductReports();
    }

    @Override
    public int updateProductShelves(String productId) {
        return sqlSession.getMapper(ProductMapper.class).updateProductShelves(productId);
    }

    @Override
    public int updateProductState(String productId, Integer newState) {
        return sqlSession.getMapper(ProductMapper.class).updateProductState(productId, newState);
    }

    @Override
    public int deleteProductById(String productId) {
        return sqlSession.getMapper(ProductMapper.class).deleteProductById(productId);
    }

    @Override
    public int updateDeleteState(String productId) {
        return sqlSession.getMapper(ProductMapper.class).updateDeleteState(productId);
    }

    @Override
    public int updateProduct(Product product) {
        return sqlSession.getMapper(ProductMapper.class).updateProduct(product);
    }
}
